<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Service\BinanceService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;

/**
 * 币安控制器.
 *
 * @Controller
 * Class BinanceController
 *
 * author TG:@lazy_sheeps or GM:wuge9802@gmail.com
 */
class BinanceController extends AbstractController
{
    /**
     * @Inject
     */
    public BinanceService $service;

    /**
     * 列表.
     *
     * @PostMapping(path="create_order")
     */
    public function createOrder()
    {
        $symbol = strtoupper(trim($this->request->input('symbol'))) ?? 'BTC';
        $symbol = $symbol . 'USDT';
        $percentage = $this->request->input('percentage');
        $amount = (int) $this->request->input('amount') ?? 10;
        $result = $this->service->adjustOrders($symbol, $percentage, $amount);
        $this->success($result);
    }
}
